package algorithm;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Random;

public class leetcode_0710 {

    class Solution {

        private List<Integer> list;

        private int len;

        public Solution(int n, int[] blacklist) {
            HashSet<Integer> set = new HashSet<>();
            list = new ArrayList<>();
            for(int i=0;i<blacklist.length;++i){
                set.add(blacklist[i]);
            }
            for(int i=0;i<n;++i){
                if(!set.contains(i)){
                    list.add(i);
                }
            }
            len = list.size();
        }

        public int pick() {
            Random random = new Random();
            int nextInt = random.nextInt(len);
            return list.get(nextInt);
        }
    }
}
